package org.jground.rx.ui.zk.viewControl;

import org.jground.rx.IRXObject;
import org.jground.rx.RXView;
import org.jground.rx.ui.IUIAttribute;
import org.jground.rx.ui.zk.UIFrame;
import org.zkoss.zk.ui.Component;

public class UIAttributeComponent extends UIAttributeBase {

    public UIAttributeComponent() {
        super();
    }

    private UIAttributeComponent(UIFrame uiFrame, RXView moControl) {
        super(uiFrame, moControl);
        super.uiAttributeView = UIAttributeViewControlFactory.create(uiFrame, moControl);
        super.addToControlComponent(uiAttributeView.getComponent());
    }

    public IUIAttribute<Component,UIFrame> createNew(UIFrame uiFrame, RXView moControl) {
        return new UIAttributeComponent(uiFrame, moControl);
    }

    public IRXObject updateData() {
        if (uiAttributeView instanceof UIAttributeControlComponent) {
            UIAttributeControlComponent ui = (UIAttributeControlComponent) uiAttributeView;
            ui.update();
        }
        return super.updateData();
    }

}
